package com.us.dao;

import org.nutz.dao.impl.NutDao;
import org.nutz.ioc.Ioc;
import org.nutz.ioc.impl.NutIoc;
import org.nutz.ioc.loader.json.JsonLoader;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.us.vo.User;

public class Dao extends NutDao implements IDao {

    protected NutDao dao;

    public NutDao getDao() {
        if (dao == null) {
            Ioc ioc = new NutIoc(new JsonLoader("dataSource.json"));
            ComboPooledDataSource ds = ioc.get(ComboPooledDataSource.class, "dataSource");
            dao = new NutDao(ds);
        }
        return dao;
    }

    /**
     * 作用:获取当前用户
     */
    public User curent() {
        return dao.fetch(User.class, 1);
    }
}
